<?xml version="1.0" encoding="utf-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">
		
	<h:form id="form_servidorhabilitado">
		<p:panel id="pn_servidorhabilitado" header="Ativar cadastro">
			<p:messages id="messages" showDetail="true" autoUpdate="true"/>
					
			<h:panelGrid columns="4">
				<p:outputLabel for="siape" value="Siape: " />
				<p:inputText id="siape"
					value="#{buscarServidorHabilitadoBean.siape}">
					<f:validateLongRange/>
				</p:inputText>
				<p:watermark for="siape" value="1234" />			
				
				<!-- Nome do Item -->
				<p:outputLabel for="nomeServidor" value="Nome servidor: " />
				<p:inputText class="defaultBoxRadius" id="nomeServidor"
					value="#{buscarServidorHabilitadoBean.nomeServidor}" 
					size="45" required="false">
					<f:validateLength maximum="90" />
					<f:validateRegex pattern="[A-Za-zÀ-ú ]*" />
					<p:ajax event="keyup" update="servidores"
						listener="#{buscarServidorHabilitadoBean.listarServidoresPorNome}">
					</p:ajax>
				</p:inputText>
				<p:watermark for="nomeServidor" value="João da Silva" />					
			</h:panelGrid>
			
			<h:panelGrid columns="2">
				<p:commandButton id="bt_listarservidor" value="Pesquisar" ajax="false"
					actionListener="#{buscarServidorHabilitadoBean.listarServidorHabilitado}" />
					
				<p:commandButton id="bt_limpar" value="Limpar">
					<p:ajax update="form_servidorhabilitado" resetValues="true" />
				</p:commandButton>				
			</h:panelGrid>
			
			<p:defaultCommand target="bt_listarservidor" />			
			<p:blockUI block="pn_servidorhabilitado" trigger="bt_listarservidor" />
			
			<p:dataTable id="servidores" var="servidor" 
				value="#{buscarServidorHabilitadoBean.servidores}">
			
				<p:column headerText="Nome do servidor">
					<h:outputText value="#{servidor.nomePessoa}" />
				</p:column>
				
				<p:column headerText="E-mail">
					<h:outputText value="#{servidor.email}" />
				</p:column>
				
				<p:column headerText="Titulação">
					<h:outputText value="#{servidor.titulacao.nome}" />
				</p:column>
				
				<p:column headerText="Campus">
					<h:outputText value="#{servidor.campus.nome}" />
				</p:column>
				
				<p:column headerText="Departamento">
					<h:outputText value="#{servidor.departamento.nome}" />
				</p:column>

				<p:column headerText="Opções">
					<p:panelGrid columns="1">

						<p:commandLink id="cl_habilitar" ajax="false" immediate="true"
							action="#{buscarServidorHabilitadoBean.editarServidor(servidor)}">
							<h:outputText value="Habilitar" />
						</p:commandLink>
						
					</p:panelGrid>
				</p:column>
			</p:dataTable>			
		</p:panel>
	</h:form>
		
</ui:composition>